package server

import (
	"io/fs"
	"os"
	"path/filepath"
	"strings"
)

func IsPublic(Upath string) bool {
	rootpath, _ := os.Getwd()
	var flagbool bool = false
	filepath.Walk(filepath.Join(rootpath, "public"), func(path string, info fs.FileInfo, err error) error {
		if info.IsDir() {
			return nil
		}
		dst_path := strings.ReplaceAll(path, rootpath, "")
		dst_path = strings.ReplaceAll(dst_path, "\\", "/")
		dst_path = dst_path[7:]
		if dst_path == Upath {
			flagbool = true
		}
		return nil
	})
	return flagbool
}
